<html>
<%@ page language="java" errorPage="/error.jsp" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" %>
<%@include file="/quick/include/common.jsp"%>
<%@include file="/quick/include/globalScope.jsp"%>
  <head>
    <title><c:out value="${model.title}"/></title>
  </head>

<TABLE class=mainTable cellSpacing=0 cellPadding=0 width="80%" align=center border=0>
<TBODY>
<TR>
<TD background="<c:url value="/images/table_title.jpg"/>" colSpan=6><SPAN ><b>校外考试报名统计</b></SPAN></TD></TR>

<TR>
<TD >
	<DIV align=right>学年：</DIV>
</TD>
<TD>
	<select name="schoolYear" disabled style="width:150px">
	  <c:forEach var='year' items="${model.years}">
	     <c:choose>
	       <c:when test="${year.CODE==model.currentYear}">
		      <option value="<c:out value="${year.CODE}"/>" selected><c:out value="${year.NAME}"/></option>
	       </c:when>
	       <c:otherwise>
		      <option value="<c:out value="${year.CODE}"/>"><c:out value="${year.NAME}"/></option>
	       </c:otherwise>
	     </c:choose>
	  </c:forEach>
	</select>
</TD>
<TD>
	<DIV align=right>学期：</DIV>
</TD>
<TD>
	<select name="schoolSemester" disabled style="width:150px">
	   <option value=1  <c:if test="${model.currentSemester=='1'}"> selected</c:if> >第一学期</option>
       <option value=2  <c:if test="${model.currentSemester=='2'}"> selected</c:if> >第二学期</option>
	</select>
</TD>
<TD>
	<DIV align=right>考试名称：</DIV>
</TD>
<TD >

	<select name="examType" style="width:200px" onchange="f_set('1',this.value)">
		<option value="">全部</option>
           <c:forEach var='examType' items="${model.examTypes}">
		       <option value="<c:out value="${examType.CODE}"/>"  <c:if test="${model.currentType==examType.CODE}"> selected</c:if>><c:out value="${examType.NAME}"/></option>
		   </c:forEach>
	</select>
</TD>
</TR>
<TR>
<TD>
	<DIV align=right>院系：</DIV>
</TD>
<TD >
	<select name="department" style="width:200px" onchange="f_set('2',this.value)">
		<option value="">全部</option>
           <c:forEach var='department' items="${model.departments}">
		       <option value="<c:out value="${department.COLLEGE_DEPARTMENT}"/>"  <c:if test="${model.currentDepartment==department.COLLEGE_DEPARTMENT}"> selected</c:if>><c:out value="${department.COLLEGE_NAME}"/></option>
		   </c:forEach>
	</select>
</TD>
<TD>
	<DIV align=right>专业：</DIV>
</TD>
<TD >
	<select name="major" style="width:200px" onchange="f_set('3',this.value)">
		<option value="">全部</option>
           <c:forEach var='major' items="${model.majors}">
		       <option value="<c:out value="${major.MAJOR}"/>"  <c:if test="${model.currentMajor==major.MAJOR}"> selected</c:if>><c:out value="${major.MAJOR_NAME}"/></option>
		   </c:forEach>
	</select>
</TD>
<TD colspan=2>
  &nbsp;
</TD>
</TR>
<TR>
<TD colSpan=6>
<DIV align=center>
<INPUT class=INPUT_button id=confirm onclick="f_statistics(1)" type=submit value=统计(明细) name=confirm> 
<INPUT class=INPUT_button id=confirm2 onclick="f_statistics(2)" type=submit value=统计(院系) name=confirm2> 
</DIV></TD></TR></TBODY></TABLE> 


<br>
<c:if test="${model.statisticsData!=null  }">
<TABLE class=mainTable cellSpacing=0 cellPadding=0 width="80%" align=center border=0>
<TBODY>
<TR>
<TD height=14>
<DIV align=center><b>年级</b></DIV></TD>
<TD height=14>
<DIV align=center><b>院系</b></DIV></TD>
<TD>
<DIV align=center><b>专业</b></DIV></TD>
<TD>
<DIV align=center><b>班级</b></DIV></TD>
<TD>
<DIV align=center><b>已付费人数</b></DIV></TD>
<TD>
<DIV align=center><b>未付费人数</b></DIV></TD>
</TR>
<c:forEach var="rec" items="${model.statisticsData }">
	<TR>
		<TD>
		<DIV align=center><c:out value="${rec.GRADE }"/> </DIV></TD>
		<TD>
		<DIV align=center><c:out value="${rec.COLLEGE_NAME }"/></DIV></TD>
		<TD>
		<DIV align=center><c:out value="${rec.MAJOR_NAME }"/></DIV></TD>
		<TD>
		<DIV align=center><c:out value="${rec.CLASS_NAME }"/></DIV></TD>
		<TD>
		<DIV align=center>
		  <A onclick="javscript:f_showStudents('<c:out value="${rec.GRADE }"/>','<c:out value="${rec.MAJOR }"/>','<c:out value="${rec.CLASS_NO }"/>','<c:out value="${rec.EXAM_TYPE }"/>','Y')" href="#">
		     <c:out value="${rec.PAYED }"/>
		  </A></DIV></TD>
		<TD>
		<DIV align=center>
		  <A onclick="f_showStudents('<c:out value="${rec.GRADE }"/>','<c:out value="${rec.MAJOR }"/>','<c:out value="${rec.CLASS_NO }"/>','<c:out value="${rec.EXAM_TYPE }"/>','N')" href="#">
		    <c:out value="${rec.UNPAY }"/>
		  </A></DIV></TD>
	</TR>
</c:forEach>
</TBODY>
</TABLE>
<div id="subWindow-win"  style='display:none'></div>
<div id='subTable_html' style='display:none'></div>
</c:if>
<script type="text/javascript">

var currentYear="<c:out value='${model.currentYear}'/>";
var currentSemester="<c:out value='${model.currentSemester}'/>";
var currentType="<c:out value='${model.currentType}'/>";
var currentDepartment="<c:out value='${model.currentDepartment}'/>";
var currentMajor="<c:out value='${model.currentMajor}'/>";

function f_showStudents(grade,majorNo,classNo,examType,status){
   var postData={
	     'tableName':'V_EXTERNAL_EXAM_STUDENTS',
	     'rowsOfPage':'300',
	     'SCHOOL_YEAR':currentYear,
	     'SCHOOL_SEMESTER':currentSemester,
	     'GRADE':grade,
	     'MAJOR':majorNo ,
	     'CLASS_NO':classNo ,
	     'EXAM_TYPE':examType ,
	     'STATUS':status
     };
   globalScope._model(postData,function(responseText){
        var htmlDiv=Ext.get("subTable_html");
	    htmlDiv.dom.innerHTML=responseText;
	    
	    var span=htmlDiv.first("span").dom;
	    var table=htmlDiv.first("table").dom;
	    
	    var columns=Ext.decode(span.innerText);
	    var gridColumns=[];
	    Ext.each(Ext.ux.clone(columns),function(col){
	      if(col.gridDisplay){
	       gridColumns.push(col);
	      } 
	    });
	    var subGrid= new Ext.quick.QuickGrid(table, {
	      stripeRows: true, // stripe alternate rows
	      enableDragDrop:false,
	      excelTitle:"评教结果统计", 
		  clicksToEdit:1,
		  autoScroll:true,
		  'remove':true,
		  'smConfig':{/*handleMouseDown:Ext.emptyFn*/}
	    },gridColumns);
	    
	
	var desc=(status=='Y')?'已付费':'未付费';    
	var subWin = new Ext.Window({
	    layout:'fit',
	    title:"校外考试报名"+desc+"情况",
	    width:1200,
	    autoScroll:true,
	    height:600,
	    closeAction:'hide',
	    buttonAlign:'center',
	    items: [subGrid],
	    buttons: [{
	        text:jspVarHandler.fmt_button_close,
	        handler:function(){subWin.close()}
	    }]
	});
    subWin.render(document.body);
	subWin.show();  
	    
   },false);  
}

function f_set(f,v){
  var url="<c:url value="/educational/examEntry/statistics.html"/>";
  var matrix=[];
  switch(f){
    case '1'://选择当前报名类型
       currentType=v;
       matrix.push(["currentType",currentType]);
      break;  
    case '2'://设置当前系
      currentDepartment=v;
      matrix.push(["currentType",currentType]);
      matrix.push(["currentDepartment",currentDepartment]);
      break;  
    case '3'://设置当前专业
      currentMajor=v;
      matrix.push(["currentType",currentType]);
      matrix.push(["currentDepartment",currentDepartment]);
      matrix.push(["currentMajor",currentMajor]);
      break;  
  }
  var form=createForm(url,matrix);
  form.submit();
}

function f_statistics(f){
  var url="<c:url value="/educational/examEntry/statistics.html"/>";
  var matrix=[["cmd","STATISTICS_DETAIL"]];
  matrix.push(["currentType",currentType]);
  matrix.push(["currentDepartment",currentDepartment]);
  matrix.push(["currentMajor",currentMajor]);
  var form=createForm(url,matrix);
  form.submit();
}  

</script>

</html>   
